home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / totdoc.zip / CHAPT2.TXT < prev    next >
Text File  |  1991-02-11  |  27KB  |  535 lines

  1.                                                                  Getting Started
  2.  
  3.  
  4.  
  5.          "It is common sense to take a method and try it. If it fails, admit it
  6.          frankly and try another. But above all, try something."
  7.  
  8.                                                            Franklin D. Roosevelt
  9.  
  10.  
  11.  
  12. Installing the Toolkit
  13.          The Toolkit is available in a variety of disk densities and sizes. This
  14.          section assumes that you are installing the software from a two disk
  15.          set. If you are using a single disk set, simply assume that all the
  16.          files are contained on a single disk and ignore the instructions for
  17.          inserting the second disk.
  18.  
  19.          The program disk includes an installation program INSTALL.EXE. This
  20.          program can be used to automatically install the software onto your
  21.          hard disk. It will prompt you to enter the appropriate source and tar-
  22.          get directories, and will not modify your CONFIG.SYS and AUTOEXEC.BAT
  23.          files. Alternatively, you may install the Toolkit manually. Please note
  24.          that the files are stored on disk in compressed form, and must be
  25.          uncompressed (decompressed?) before they can be used.
  26.  
  27.  
  28. Using INSTALL.EXE
  29.          The Install program will transfer the Toolkit files from the diskettes
  30.          to a specified hard drive. To run the install program, insert the
  31.          Source Disk in drive A (or another floppy drive) and then:
  32.  
  33.          q    Type the command: A:INSTALL [KEYCAP].
  34.          q    Press [KEYCAP] at the installation screen.
  35.  
  36.          q    Follow the prompts.
  37.          It is recommended that you install the source files in a sub-directory
  38.          TOT beneath the main Turbo Pascal directory. Similarly, the demo files
  39.          should be installed in a TOTDEM subdirectory.
  40.  
  41.          During the installation process, files will be copied from the Toolkit
  42.          disks to your hard drive. The files will then be compressed. Once the
  43.          files have been installed, the Installation program will ask if you
  44.          want to view the README file. This file contains last-minute details
  45.          about the Toolkit. A following section describes how to view the README
  46.          file after installation.
  47.          If the installation is not successful, follow the manual installation
  48.          method described in the next section.
  49.  
  50.  
  51. 2-2                                                                 User's Guide
  52. --------------------------------------------------------------------------------
  53.  
  54. Manual Installation
  55.  
  56.          The disks contain the following files:
  57.          INSTALL.EXE     the Toolkit Installation program
  58.  
  59.          SOURCE.EXE      a self-extracting file which contains the .PAS source
  60.                          files for the Toolkit units
  61.          DEMO.EXE        a self-extracting file which contains the .PAS demon-
  62.                          stration files, which illustrate how to use the Toolkit
  63.  
  64.          DOCS.EXE        a self-extracting file containing all this documenta-
  65.                          tion in ASCII form
  66.          README.COM      a self-displaying text file which lists all the last-
  67.                          minute changes and enhancements
  68.  
  69.          REGISTER.EXE    a self-extracting file which contains all the ShareWare
  70.                          information and instructions
  71.  
  72.  
  73.          We recommend that the source files are installed in a separate sub-
  74.          directory "underneath" the compiler directory. For example, if your
  75.          compiler is stored in the directory C:\TP, then create a directory
  76.          C:\TP\TOT. You can insert the source disk in the A drive and install
  77.          the source files as follows:
  78.                   C: [KEYCAP]
  79.                   MD\TP\TOT [KEYCAP]
  80.                   CD\TP\TOT [KEYCAP]
  81.                   A:SOURCE [KEYCAP]
  82.  
  83.  
  84.          The SOURCE.EXE program will then place all the source code files in the
  85.          newly created directory. The README.COM file should also be copied to
  86.          the TOT sub-directory.
  87.  
  88.                   COPY A:README.COM [KEYCAP]
  89.  
  90.  
  91.          Although not essential, the demonstration files are referred to
  92.          throughout the documentation and it is recommended that you do install
  93.          them. Furthermore, it is recommended that you install them in a sepa-
  94.          rate subdirectory as follows:
  95.                   C: [KEYCAP]
  96.                   MD\TP\TOTDEMO [KEYCAP]
  97.                   CD\TP\TOTDEMO [KEYCAP]
  98.                   A:DEMO [KEYCAP]
  99.  
  100.  
  101.  
  102.  
  103. Getting Started                                                              2-3
  104. --------------------------------------------------------------------------------
  105.  
  106.          You do not need to install the DOCS.EXE and REGISTER.EXE files, since
  107.          you are a registered user and you are reading the documentation. These
  108.          files are included so that you may give an evaluation copy of the
  109.          Toolkit to a colleague who may try the software. Refer to the License
  110.          Agreement for further information.
  111.  
  112. The Toolkit Files
  113.          Listed below are the source files that have been installed on your hard
  114.          disk:
  115.  
  116.          TOTFLAGS.INC    contains global compiler directives
  117.          TOTLOOK.PAS     controls the overall look and feel of your programs
  118.  
  119.          TOTREAL.PAS     provides numeric co-processor support and supports
  120.                          extended reals
  121.          TOTSYS.PAS      contains objects for ascertaining hardware and operat-
  122.                          ing system configurations
  123.  
  124.          TOTINPUT.PAS    provides mouse and keyboard support
  125.          TOTFAST.PAS     supports writing to physical and virtual screens
  126.  
  127.          TOTWIN.PAS      contains a variety of window objects
  128.          TOTMSG.PAS      provides objects for displaying messages and prompts in
  129.                          Pop-up windows
  130.  
  131.          TOTLINK.PAS     includes a variety of objects for managing linked lists
  132.          TOTLIST.PAS     provides objects for displaying string arrays or linked
  133.                          lists in a window
  134.  
  135.          TOTDIR.PAS      includes a directory display object
  136.          TOTIO1,2,3.PAS  three units for building full screen input
  137.  
  138.          TOTMENU.PAS     includes routines for building pop-up and pull-down
  139.                          menus
  140.          TOTSTR.PAS      contains a host of string manipulation functions
  141.  
  142.          TOTDATE.PAS     includes a set of functions for managing Julian and
  143.                          Gregorian dates
  144.          TOTMISC.PAS     provides a potpourri of procedures and functions
  145.  
  146.          TOTBUILD.PAS    used to re-build all the TOT TPUs
  147.  
  148.  
  149.          In addition to the source code files, there are a host of demonstration
  150.          files. All the demonstration filenames begin with DEM. The files which
  151.          demonstrate how to extend the Toolkit begin with EXT. The major demon-
  152.  
  153. 2-4                                                                 User's Guide
  154. --------------------------------------------------------------------------------
  155.  
  156.          stration file is DEMTOT.PAS. All the other files are designed to be
  157.          small and concise illustrations of how to get the most from the
  158.          Toolkit.
  159.  
  160.  
  161.  
  162. The README File
  163.          The file README.COM is actually a self-displaying text file which con-
  164.          tains any last-minute changes or additions to the documentation. To
  165.          view the contents of the README file, simply change the default
  166.          directory to the TOT source and execute README, e.g.
  167.  
  168.                   CD\TP\TOT [KEYCAP]
  169.                   README [KEYCAP]
  170.  
  171.  
  172. Configuring Turbo Pascal
  173.  
  174.          Having installed the Toolkit, you must configure Turbo Pascal so the
  175.          compiler knows where to locate the Toolkit files. Configure the inte-
  176.          grated environment as follows:
  177.          q    Execute the IDE by changing the default directory to the main
  178.               Turbo Pascal directory, and enter TURBO.
  179.  
  180.          q    Select the Directories item from the Options menu. The Directories
  181.               dialog box will then be displayed. Fig 2.1 illustrates the Pascal
  182.               6.0 dialog box.
  183.          q    You must now add the C:\TURBO\TOT directory (or whichever direc-
  184.               tory you have chosen for the Toolkit) to the Unit, Include and
  185.               Object input fields. If an entry already exists in the field,
  186.               press the right cursor and add a semi-colon before entering the
  187.               Toolkit directory. Note: do not have more than one directory in
  188.               the EXE/TPU input field - this must be a single directory identi-
  189.               fying where the compiler should locate compiled files.
  190.  
  191.          q    Save the options by selecting Save from the Options menu.
  192.  
  193.  
  194. Figure 2.1                                                              [SCREEN]
  195. Configuring the IDE
  196.  
  197.  
  198.          If you are using the command line version of the compiler, i.e. TPC.EXE
  199.          or TPCX.EXE, then you must add the Toolkit directory to the Unit,
  200.          Include and Source parameters in the TPC(X).CFG file. Listed below is
  201.          an example of a TPC.CFG file:
  202.  
  203.  
  204.  
  205. Getting Started                                                              2-5
  206. --------------------------------------------------------------------------------
  207.  
  208.                /L
  209.                /M
  210.                /IC:\TURBO\TOT;C:\TURBO\MISC
  211.                /UC:\TURBO\TOT
  212.                /OC:\TURBO\TOT
  213.                /EC:\TURBO\MYPROGS
  214.  
  215.  
  216.          Turbo Pascal 5.5 users can use the TPCONFIG.EXE program to create a
  217.          TPC.CFG file from the IDE settings, and vice verse.
  218.          For further configuration information refer to the Turbo Pascal User's
  219.          Guide.
  220.  
  221.  
  222.  
  223. Unit Summary
  224.          Listed below is a description of the features in each of the major
  225.          units:
  226.  
  227.  
  228.          totLOOK    This unit is designed to help you control the look and feel
  229.                     of large programs. A global object, LOOKTOT, defines the
  230.                     default colors to be used when displaying windows, menus and
  231.                     lists.
  232.  
  233.          totREAL    This small unit controls the REAL type. Unless the compiler
  234.                     directive FLOAT is specified (in the TOTFLAGS.INC file -
  235.                     discussed later), the types SINGLE, DOUBLE, EXTENDED and
  236.                     COMP are type cast to the base type REAL.
  237.          totSYS     This unit provides four objects which can be used to deter-
  238.                     mine the hardware and operating system configurations of the
  239.                     PC on which your programs are running. The DisplayOBJ object
  240.                     provides information about the display: whether it is color
  241.                     or monochrome, what is the width and depth of the screen,
  242.                     and the object includes methods for setting the screen into
  243.                     and out of condensed mode, i.e. 43 or 50 line mode. The
  244.                     EquipOBJ object provides information about the PC peripheral
  245.                     devices, e.g. how many serial and parallel ports there are,
  246.                     if a math chip is present, how many floppy drives, etc. The
  247.                     MemOBJ object provides information about base memory, as
  248.                     well as extended and expanded memory. The OSOBJ provides
  249.                     information about the operating system, e.g. the DOS version
  250.                     number, the country configuration, and the characters used
  251.                     for currency, date and time separators.
  252.  
  253.  
  254.  
  255. 2-6                                                                 User's Guide
  256. --------------------------------------------------------------------------------
  257.  
  258.          totINPUT   The two main objects in this unit, MouseOBJ and KeyOBJ, are
  259.                     used to detect and control mouse and keyboard activity. The
  260.                     MouseOBJ detects if a mouse is present and includes a
  261.                     variety of methods for controlling the mouse shape and
  262.                     location. The KeyOBJ is the primary input object and detects
  263.                     both keyboard and mouse button activity. There are methods
  264.                     to get and set the status of the Caps Lock, Num Lock and
  265.                     Scroll Lock keys, as well as routines to stuff or erase
  266.                     characters with a special keyboard type-ahead buffer.
  267.  
  268.          totFAST    The totFAST unit provides the main screen writing primi-
  269.                     tives, and contains four main objects: WriteOBJ, ScreenOBJ,
  270.                     ScrollOBJ and ShadowOBJ. The WriteOBJ object controls the
  271.                     screen writing techniques used throughout the Toolkit. If
  272.                     you do not want to use the Toolkit screen writing algo-
  273.                     rithms, you can create a descendent object and substitute
  274.                     any of the WriteOBJ methods. The ScreenOBJ object contains
  275.                     all the methods for writing formatted data to the screen.
  276.                     There are routines to write text to any location on the
  277.                     screen with right, left or center justification. As well as
  278.                     routines for drawing boxes and lines which automatically use
  279.                     line joining characters if they cross over another line.
  280.                     ScreenOBJ also supports virtual screens which can be slid or
  281.                     popped onto the visible screen at any time. Virtual screens
  282.                     can either be copied from the visible screen or created from
  283.                     scratch. The ScrollOBJ object controls the look and feel of
  284.                     the scroll bars used throughout the Toolkit. The ShadowOBJ
  285.                     controls the look and feel of the shadows used throughout
  286.                     the system. Shadows may be set up or down, right or left,
  287.                     and the depth and color of the shadow can be defined.
  288.          totWIN     This unit provides a variety of window objects for writing
  289.                     text in a window. The primary object is WinOBJ, which
  290.                     provides the methods for popping a window onto the display.
  291.                     You can specify the window attributes such as display
  292.                     colors, size and title. When a window is activated, the
  293.                     Toolkit automatically restricts screen writing to within the
  294.                     window area. When the window is removed, the original screen
  295.                     contents are restored and the cursor is repositioned in its
  296.                     original position. The MoveWinOBJ offers all the features of
  297.                     the WinOBJ, but the user can drag or move the window around
  298.                     the screen. The ScrollWinOBJ is a moveable window object
  299.                     that optionally supports horizontal and vertical scroll
  300.                     bars. Finally, the StretchWinOBJ is a moveable, scrollable
  301.                     window that allows the user to stretch the window into
  302.                     different shapes by dragging the lower-right window corner.
  303.  
  304.          totMSG     The totMSG unit provides a suite of objects for displaying
  305.                     pop-up messages to the user. In the next section, this unit
  306.                     forms part of a demonstration on how to use the Toolkit.
  307.  
  308.  
  309. Getting Started                                                              2-7
  310. --------------------------------------------------------------------------------
  311.  
  312.          totLINK    One of the least understood elements of contemporary pro-
  313.                     gramming techniques is the creation and maintenance of
  314.                     linked lists. This unit provides a number of objects for
  315.                     building doubly-linked lists. Linked lists allow you to
  316.                     create lists of variable size, unlike arrays where you have
  317.                     to specify the total size of the array at compile time.
  318.                     Linked lists are ideal for reading directories, text files
  319.                     or database records. The linked list engine provides rou-
  320.                     tines for adding, deleting and moving entries in the list,
  321.                     as well as automatic sorting.
  322.  
  323.          totLIST    This unit provides the ListOBJ for displaying arrays or
  324.                     linked lists in a stretchable window. List objects can be
  325.                     used to display text files, data base records, or any list
  326.                     in a window. Lists can be displayed in multiple columns, and
  327.                     the user may optionally select one or more items from the
  328.                     list.
  329.          totDIR     Most programs require the user to select a filename. The
  330.                     DirOBJ provides a very quick and convenient way of display-
  331.                     ing a dialog box from which the user can choose a file, or
  332.                     enter a new filename.
  333.  
  334.          totIO1     The most used element of TechnoJock's Turbo Toolkit was the
  335.                     screen IO, i.e. the full screen input routines. The Object
  336.                     Toolkit dedicates three units to full screen input objects.
  337.                     The totIO1 unit provides objects for defining hotkeys,
  338.                     buttons, 3D buttons, check boxes and radio buttons, as well
  339.                     as the IO event manager ActionOBJ.
  340.          totIO2     totIO2 provides objects for string input (including lateral
  341.                     scrolling), integer/real/date/hex input with automatic input
  342.                     and range validation, formatted string input for telephone
  343.                     number input and the like, and a list unit for displaying a
  344.                     scrollable list as an input field.
  345.  
  346.          totIO3     totIO3 provides objects for creating memo fields, i.e.
  347.                     multi-line fields that provide full word wrapping. Either a
  348.                     linked list or an array can be assigned to the memo field.
  349.          totMENU    The totMENU unit provides objects for displaying full-screen
  350.                     menus, as well as multilevel pull-down menus.
  351.  
  352.          totSTR     The totSTR unit provides a wealth of routines for formatting
  353.                     and converting strings. There are routines to convert inte-
  354.                     gers, reals and HEX to string and vice verse. There are also
  355.                     routines to truncate and extend strings, delete characters
  356.                     from strings, count words, adjust case, etc.
  357.  
  358.  
  359.  
  360. 2-8                                                                 User's Guide
  361. --------------------------------------------------------------------------------
  362.  
  363.          totDATE    Date manipulation is a snap with the totDATE unit. This unit
  364.                     provides a set of functions for converting to and from
  365.                     Julian dates. The unit supports eight (count 'em) different
  366.                     date formats for national and international use.
  367.  
  368.          totMISC    This unit contains a potpourri of procedures and functions
  369.                     that didn't fit anywhere else in the Toolkit. There are
  370.                     routines for validating filenames, checking the status of
  371.                     the printer, copying files, range checking integers, and
  372.                     more.
  373.  
  374.  
  375. Compiling the Demo Programs - A Quick Start
  376.  
  377.          Enough is enough. You must want to try it by now. If you have not yet
  378.          installed the Toolkit or configured Turbo Pascal, do so now. Full
  379.          instructions were provided earlier in this chapter.
  380.          Start the IDE and use the File Change Dir option to change the working
  381.          directory to C:\TURBO\TOTDEMO (or wherever you installed the demo
  382.          files). Choose File Open and load the file DEMMS1.PAS. This filename is
  383.          an abbreviation of DEMO-MESSAGE-ONE, the first demo of the totMSG unit.
  384.  
  385.          Listed below are the file contents:
  386.  
  387.  
  388.          program DemoMessage1;
  389.          {demms1}
  390.          Uses DOS, CRT,
  391.               totFAST, totMSG;
  392.  
  393.          Var  MsgWin : MessageOBJ;
  394.          begin
  395.             Screen.Clear(white,'░'); {paint the screen}
  396.             with MsgWin do
  397.             begin
  398.                Init(1,' Message ');
  399.                AddLine('');
  400.                AddLine('The message unit provides a');
  401.                AddLine('very easy way of displaying');
  402.                AddLine('pop-up messages in a move-');
  403.                AddLine('able window.');
  404.                AddLine('');
  405.                Show;
  406.                Done;
  407.             end;
  408.          end.
  409.  
  410.  
  411.  
  412. Getting Started                                                              2-9
  413. --------------------------------------------------------------------------------
  414.  
  415.          The demo program uses methods from the totFAST and totMSG units, so
  416.          they are included in the Uses statement. The VAR statement declares an
  417.          object variable called MsgWin which is of type MessageOBJ. This is the
  418.          main object used for displaying messages.
  419.  
  420.          The first statement of the program:
  421.                   Screen.Clear(white,'░');
  422.  
  423.          calls the Clear method (or procedure in the old terminology) from the
  424.          Screen object. Screen is a globally declared object in the totFAST unit
  425.          and controls the writing to the screen. The Clear method is used to
  426.          clear the screen, and the two parameters identify the display color and
  427.          the character used to fill the screen.
  428.          The remaining statements all affect the MsgWin object, so to abbreviate
  429.          the code, the "with var do" shortcut is used. Every Toolkit object must
  430.          be initialized before the object methods can be called, and this is
  431.          always achieved with the INIT statement. In the case of MessageOBJ
  432.          objects, INIT must be passed two parameters: the first indicates the
  433.          window border style (1 for a single line box), and the second the
  434.          window title. The AddLine method is called multiple times to add the
  435.          message text. The Show method is then called to instruct the Toolkit to
  436.          display the message. Finally, when the user has removed the message,
  437.          the WinOBJ is disposed of by calling the DONE method (known as a
  438.          destructor). That's all there is to it.
  439.  
  440.          Select Run Run (or press [KEYCAP]) to execute the demo program. Fig 2.2
  441.          illustrates the screen that should be displayed. (If the program did
  442.          not run successfully, refer to the next section for the probable
  443.          cause.)
  444.          The message window can be dragged around the screen using the Mouse by
  445.          moving the mouse cursor to the top of the window, and holding down the
  446.          left mouse button. While the button remains depressed the window can be
  447.          dragged around the screen. Using the keyboard, the window can be moved
  448.          by pressing the [KEYCAP] key and then using the cursor keys. The move
  449.          is terminated when [KEYCAP] is pressed.
  450.  
  451.          The message can be removed by clicking the left mouse button on the
  452.          close icon [■] at the top left of the window, by clicking the left
  453.          mouse button on the OK hot spot, or by pressing [KEYCAP] or [KEYCAP].
  454.  
  455.  
  456. Figure 2.2                                                              [SCREEN]
  457. The Message Demo
  458. Program
  459.  
  460.  
  461.  
  462. 2-10                                                                User's Guide
  463. --------------------------------------------------------------------------------
  464.  
  465. Common Problems
  466.  
  467.          Listed below are a few of the common problems that occur when you first
  468.          try to run the demo programs, together with some quick remedies.
  469.  
  470.  
  471.  
  472.          Error 15: File not found (TOTFAST.TPU)
  473.          This error is generated when the compiler cannot find the TPU file or
  474.          the associated PAS file. The most likely cause is that you have not
  475.          correctly entered the Toolkit path in the Options Directories Unit
  476.          Directories dialog box. Correct the path and try again.
  477.  
  478.  
  479.          Error 15: File not found (TOTFLAGS.INC)
  480.          Make sure that you have correctly added the Toolkit directory to the
  481.          Options Directories Include Files dialog box.
  482.  
  483.  
  484.          Error 15: File not found (TOTFAST.OBJ)
  485.          Make sure that you have correctly added the Toolkit directory to the
  486.          Options Directories Object Files dialog box.
  487.  
  488.  
  489.          Error 1: Out of memory
  490.          Turbo Pascal lacks sufficient room to compile, link, and execute your
  491.          program. The first obvious step is to remove any unnecessary memory
  492.          resident programs, not forgetting items in CONFIG.SYS like BUFFERS and
  493.          ANSI.SYS. A number of IDE settings influence the amount of memory
  494.          required to run a program. The following actions will minimize the
  495.          memory consumed:
  496.  
  497.          q     Set the Compile Destination to disk.
  498.          q     Set the Options Linker to disk.
  499.  
  500.          q     Set the Options Linker mapfile to off.
  501.          q     Set the Options Debugger so that both stand-alone and integrated
  502.                options are not selected.
  503.  
  504.          q     Edit the TOTFLAGS.INC file and enable the FINAL directive (dis-
  505.                cussed in the next chapter).
  506.          q     If the file you are editing is large, switch to a smaller file,
  507.                and specify the program filename in the Compiler Primary file
  508.                field.
  509.  
  510.          q     If you are using Turbo Pascal version 6, there are a number of
  511.                other ways to save memory, particularly if you have expanded
  512.                memory. Refer to page 147 of the 6.0 User's Guide for further
  513.                information.
  514.  
  515.  
  516. Getting Started                                                             2-11
  517. --------------------------------------------------------------------------------
  518.  
  519.          If there is still insufficient memory, remove any unnecessary memory
  520.          resident programs from memory and try again. If you can compile the
  521.          program, but not run it, drop to DOS and execute the program from the
  522.          command line. If all else fails, use the command line version of Turbo
  523.          (TPC or TPCX) to compile the program. Note that all the demo programs
  524.          included in the Toolkit will run from the integrated environment on a
  525.          640k machine when compiled in the FINAL state.
  526.  
  527.  
  528.  
  529.          Error 72: Unit file format error (...)
  530.  
  531.          This problem usually occurs when you switch from one version of Turbo
  532.          Pascal to another - TPUs created with one version of Pascal cannot be
  533.          used by another version. The solution is to select Compile Build and
  534.          force the compiler to recreate the TPU files.
  535.